package cn.company.database;

import java.sql.Connection;
import java.sql.DriverManager;
import java.util.Properties;
/**
 * 数据库连接管理类
 * @author mzba
 *
 */
public class Connections {

	private Connection conn = null;
	private Properties properties;
	private String drivers = null;
	private String url = null;
	private String user = null;
	private String password = null;
	private FileUtils fileUtils = null;
	
	public Connection getConnetion(){
		fileUtils = new FileUtils();
		properties = fileUtils.getDbInfo();
		drivers = properties.getProperty("drivers");
		url = properties.getProperty("url");
		user = properties.getProperty("user");
		password = properties.getProperty("password");
		
		try {
			Class.forName(drivers).newInstance();
			conn = DriverManager.getConnection(url, user, password);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return conn;
	}
}
